Node2D plugin example
This example shows how to create a custom 2D node and render video frames with Kanzi using that node. The example shows how to use the Kanzi Engine plugins. For Android, a shared image texture utilizing OES_EGL_image_external extension is used for streaming the video from an external context.
You can find the example in <KanziWorkspace>/Examples/Node2D_plugin.
The example plugin creates the VideoView2D node. For details on how to create a Kanzi Engine plugin, see Node3D plugin example.
The example runs on Windows and Android platforms:
- Windows platform uses Microsoft Media Foundation for video playback. You can find the source files for the Windows platform in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/platform_specific/win32/src.
- Android platform uses the native media player. You can find the source files for the Android platform in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/platform_specific/android/src.
- You can find the code common to both platforms in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/plugin.
Note To run the Node2D plugin example on Windows 10 N and Windows 10 KN versions, you must install the Media feature pack provided by Microsoft.
Using the external texture handle
Because Android’s native code and Kanzi application framework run in different context, they cannot share the GPU resources. A widely available OpenGL extension (GL_TEXTURE_EXTERNAL_OES) provides the support for external texture resources that can be shared between contexts with few limitations. The Node2D_plugin example uses the Android media player to render a video stream to a surface view that is bound to the external texture handle. On the Kanzi side, the texture of the node that renders the video is bound to the same external texture handle, and displayed in the render loop.
You can use this approach on other platforms where:
- The device supports the GL_TEXTURE_EXTERNAL_OES extension.
- A service in another context is capable of providing a texture bound to an external texture handle.
A typical example is a streaming video.
Building the plugin .dll
Kanzi Studio Preview uses the .dll file of the plugin to run the example code.
To build the plugin .dll that the example uses:
- In Visual Studio 2010 open the solution for the example <KanziWorkspace>/Examples/Node2D_plugin/Application/configs/platforms/win32.
- In Visual Studio select the GL_vs2010_Debug_DLL solution configuration.
- Build the Node2D_plugin_executable application.
When Visual Studio completes the building, it places the plugin .dll to <KanziWorkspace>/Examples/Node2D_plugin/Application/output/win32/GL_vs2010_Debug_DLL.
- Copy the <KanziWorkspace>/Examples/Node2D_plugin/Application/output/win32/GL_vs2010_Debug_DLL/Node2D_plugin.dll to <KanziWorkspace>/Examples/Node2D_plugin/Application/bin.
This is the location where the Node2D_plugin example Kanzi Studio project is configured to look for the plugin.
-
Make sure that the solution configuration you used in Visual Studio to build your application and plugin projects matches the settings of your Kanzi Studio project.
For example, if you used the GL_vs2010_Debug solution in Visual Studio, in your Kanzi Studio project in the > set:
- Preview OpenGL ES Wrapper to GL (Emulation through desktop OpenGL)
- Preview Build Configuration to Debug
- Preview Visual Studio Version to 2010
- In Kanzi Studio start the Preview. When the Preview starts, it loads the plugin .dll you built and you can interact in the Preview with the custom components defined in the application code.
See also
Kanzi Engine plugins
Examples
Open topic with navigation